package com.example.swimmingpool.interceptor;

import com.example.swimmingpool.response.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public CommonResponse<Object> exceptionHandler(Exception e) {
        log.error("异常是{}", e.getMessage());
        return CommonResponse.fail(e.getMessage());
    }
}
